const fs = require('fs');
const zlib = require('zlib');// 压缩模块

const readStream = fs.createReadStream('./public/source.txt')
const gzipStream = zlib.createGzip();// 创建一个gzip压缩实例
const writeStream = fs.createWriteStream('./public/source.txt.gz')
// 利用pipe方法将可读流和可写流连接起来
readStream.pipe(gzipStream).pipe(writeStream)
readStream.on('end',()=>{
    console.log('文件复制完成')
})

